package queue;

public class myQuece {
    public static class node{
        public int val;
        public node next;
        public node prve;

        public node(int val) {
            this.val = val;
        }
    }
  public node front;//队列的头
  public node rear;//队列的尾
  public int usesize=0;//表示列队的元素个数
    public void offer(int val){
        node Node=new node(val);
        if (front==null){
            front=Node;
            rear=Node;
        }
        rear.next=Node;
        Node.prve=rear;
        rear=Node;
        usesize++;
    }
    public int poll(){// 头部删除
        if(front==null){
            throw new RuntimeException("队列为空");
        }
        else {
            int val=front.val;
            front=front.next;
            front.prve=null;
            usesize--;
            return val;
        }
    }
    public int peek(){//获取头部元素
        if(front==null){
            throw new RuntimeException("队列为空");
        }
        else {
          return front.val;
        }
    }
    public int size(){
        return usesize;
    }

}
